<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [1,2,3];
        
        //push
        arr.push('t','a');
        console.log(arr.push('t','a'));
        console.log(arr);

        //unshift
        arr.unshift('k','u');
        console.log(arr.unshift('k','u'));
        console.log(arr);

        //pop
        arr.pop();
        console.log(arr.pop());
        console.log(arr);

        //shift
        arr.shift();
        console.log(arr.shift());
        console.log(arr);

        //reverse
        var arr1 = ['pink','blue'];
        console.log(arr1.reverse());

        //sort
        var arr2 = [6,1,2,3,4,5];
        console.log(arr2.sort());

        var arr3 = [16,1,2,32,4,555];
        arr3.sort(function(a,b){
            return a - b;//升序  b - a 降序 
        })
        console.log(arr3);

        //indexOf 
        var arr4 = ['black','blue','green','red','hot','catch'];
        alert(arr4.indexOf('red'));
        console.log(arr4.indexOf('red'));

        //lastindexOf
        console.log(arr4.lastIndexOf('red'));

        //toString
        console.log(arr4.toString);

        //join
        console.log(arr4.join(' | '));
    </script>
</body>
</html>